package cn.zn.modules.pz.cur.controller;

import cn.zn.framework.common.utils.R;
import cn.zn.modules.loan.old.inter.LoanInter;
import cn.zn.modules.loan.old.inter.vo.LoanDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("pz/cur/pzloan")
public class TpLoanController {

    @Autowired
    LoanInter loanInter;

    /**
     * 信息
     */
    @GetMapping("/info/{applyCode}")
    public R info(@PathVariable("applyCode") String applyCode) {
        if (loanInter == null) {
            return R.error("未加载借款模块");
        }
        LoanDetailVO loanDetailVO = loanInter.findByApplyCode(applyCode);

        return R.ok().put("loanDetail", loanDetailVO);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody LoanDetailVO loanDetailVO) {
        if (loanInter == null) {
            return R.error("未加载借款模块");
        }
        loanInter.saveLoan(loanDetailVO);

        return R.ok();
    }
}
